package day7.homework;

import java.util.*;

public
class Demo {
    public static
    void main(String[] args) {
        List<Card> list = new ArrayList<>();
        Set<Card> s1=new TreeSet<>();
        Set<Card> s2=new TreeSet<>();
        Set<Card> s3=new TreeSet<>();
        String[] c = {"♥", "♠", "♣", "♦"};
        String[] s = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "小王", "大王"};
        for (int i=0;i<s.length;i++){
            if (i<13){
                for (String s11:c){
                    list.add(new Card(s11+s[i],i+3));
                }
            }else {
                list.add(new Card(s[i],i+3));
            }
        }
        Collections.shuffle(list);
        for (int j=0;j<list.size();j++){
            Card card=list.get(j);
            if(j<17) s1.add(card);
            else if(j<34) s2.add(card);
            else s3.add(card);
        }
        System.out.println("农民1："+s1+"\n农民2："+s2+"\n地主："+s3);
    }
}
class Card implements Comparable<Card>{
    String str;//存储牌
    int num;//比较牌大小的基准
    public Card(String str,int num){
        this.str=str;
        this.num=num;
    }
    public String toString(){
        return str;
    }
    @Override
    public
    int compareTo(Card o) {
        int i = o.num - this.num;  // 降序排序
        if (i == 0) return this.str.compareTo(o.str);  // 数字相同按字符串排序
        return i;
    }
}
